<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小诺机器人图片下载器</title>
    
    <!-- 国内CDN资源 -->
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    
    <style>
        body {
            background-color: #f8f9fa;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 2rem 0;
            margin-bottom: 2rem;
        }
        
        .search-section {
            background: white;
            border-radius: 10px;
            padding: 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 2rem;
        }
        
        .image-card {
            transition: transform 0.3s ease;
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .image-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        }
        
        .image-card.selected {
            border: 3px solid #667eea;
        }
        
        .thumbnail {
            height: 200px;
            object-fit: cover;
            width: 100%;
        }
        
        .loading {
            display: none;
        }
        
        .progress-bar {
            transition: width 0.3s ease;
        }
        
        .filter-section {
            background: #f8f9fa;
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1rem;
        }
        
        .stats-card {
            background: white;
            border-radius: 8px;
            padding: 1rem;
            margin-bottom: 1rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <!-- 头部 -->
    <div class="header">
        <div class="container">
            <h1 class="text-center mb-0">
                <i class="fas fa-robot me-2"></i>
                小诺机器人图片下载器
            </h1>
            <p class="text-center mt-2 mb-0">一键批量下载高清机器人图片</p>
        </div>
    </div>

    <div class="container">
        <!-- 搜索区域 -->
        <div class="search-section">
            <div class="row">
                <div class="col-md-8">
                    <div class="mb-3">
                        <label class="form-label">搜索关键词</label>
                        <input type="text" class="form-control" id="keyword" placeholder="输入关键词，如：小诺机器人" value="小诺机器人">
                    </div>
                </div>
                <div class="col-md-4">
                    <label class="form-label">数量限制</label>
                    <select class="form-select" id="limit">
                        <option value="10">10张</option>
                        <option value="20" selected>20张</option>
                        <option value="50">50张</option>
                        <option value="100">100张</option>
                    </select>
                </div>
            </div>

            <!-- 筛选条件 -->
            <div class="filter-section">
                <div class="row">
                    <div class="col-md-3">
                        <label class="form-label">分辨率</label>
                        <select class="form-select" id="resolution">
                            <option value="">全部</option>
                            <option value="400x300">400x300</option>
                            <option value="600x400">600x400</option>
                            <option value="800x600">800x600</option>
                            <option value="1024x768">1024x768</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">格式</label>
                        <select class="form-select" id="format">
                            <option value="">全部</option>
                            <option value="jpg">JPG</option>
                            <option value="png">PNG</option>
                        </select>
                    </div>
                    <div class="col-md-6 d-flex align-items-end">
                        <button class="btn btn-primary me-2" onclick="searchImages()">
                            <i class="fas fa-search me-1"></i>搜索图片
                        </button>
                        <button class="btn btn-success me-2" onclick="downloadSelected()" disabled id="downloadBtn">
                            <i class="fas fa-download me-1"></i>下载选中
                        </button>
                        <button class="btn btn-info" onclick="clearSelection()">
                            <i class="fas fa-times me-1"></i>清空选择
                        </button>
                    </div>
                </div>
            </div>

            <!-- 进度条 -->
            <div class="loading" id="loadingBar">
                <div class="progress">
                    <div class="progress-bar progress-bar-striped progress-bar-animated" 
                         role="progressbar" style="width: 0%"></div>
                </div>
                <p class="text-center mt-2 mb-0" id="loadingText">正在搜索...</p>
            </div>
        </div>

        <!-- 统计信息 -->
        <div class="stats-card" id="statsCard" style="display: none;">
            <div class="row">
                <div class="col-md-4">
                    <h5 class="mb-1" id="totalImages">0</h5>
                    <small class="text-muted">找到图片</small>
                </div>
                <div class="col-md-4">
                    <h5 class="mb-1" id="selectedImages">0</h5>
                    <small class="text-muted">已选择</small>
                </div>
                <div class="col-md-4">
                    <h5 class="mb-1" id="downloadHistory">0</h5>
                    <small class="text-muted">历史下载</small>
                </div>
            </div>
        </div>

        <!-- 图片展示区域 -->
        <div class="row" id="imageContainer">
            <!-- 图片将在这里动态加载 -->
        </div>

        <!-- 无结果提示 -->
        <div class="text-center py-5" id="emptyState" style="display: none;">
            <i class="fas fa-image fa-3x text-muted mb-3"></i>
            <h5 class="text-muted">暂无图片</h5>
            <p class="text-muted">尝试调整搜索条件或关键词</p>
        </div>
    </div>

    <!-- 下载历史模态框 -->
    <div class="modal fade" id="historyModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">下载历史</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div id="historyList"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- JavaScript -->
    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
    <script src="app.js"></script>
</body>
</html>
